#根目录下执行：docker build -t micro-svr/apps/s2  -f Dockerfile .
FROM golang:1.19 AS builder

WORKDIR /build
ENV GOPROXY https://goproxy.cn
COPY go.mod .
COPY go.sum .
RUN go mod download

COPY . .
RUN CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o s2 /build/apps/s2/cmd

FROM ubuntu
ENV TZ Asia/Shanghai

WORKDIR /app
COPY --from=builder /build/s2 /app/
COPY --from=builder /build/apps/s2/configs /app/configs

CMD ["/app/s2","-log.dir","/data/logs/s2","-conf","/app/configs","-disc_url","nacos://118.195.198.233:8848?namespace=public&appid=s2-svr"]

###################################################
#根目录下执行：docker build -t micro-svr/apps/s2  -f Dockerfile .
#FROM golang:1.17-alpine AS builder

#WORKDIR /build
#RUN adduser -u 10001 -D app-runner

#ENV GOPROXY https://goproxy.cn
#COPY go.mod .
#COPY go.sum .
#RUN go mod download

#COPY . .
#RUN CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o micro-svr/apps/s2 ./cmd

#FROM alpine AS final
#WORKDIR /app
#COPY --from=builder /build/micro-svr/apps/s2 /app/
#COPY --from=builder /build/configs /app/configs
#COPY --from=builder /etc/passwd /etc/passwd
#COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

#USER app-runner

#CMD ["/app/micro-svr/apps/s2","-log.dir","/data/logs/micro-svr/apps/s2","-conf","/app/configs"]
